<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

use App\Models\Config;

class ConfigController extends Controller
{

	
	/*
	 * 站点配置
	 * 
	 * */
	protected function siteconfig(Request $request){
		if($request->isMethod('post')){
			$input = $request->only('shop_name','wx_pay','is_cod','shop_notice','shop_hours','address','phone','offer_price','freight','shipping_area');
			foreach ($input as $k=>$v) {
				Config::where('name',$k)->update(['value'=>$v]);	
			}
			return response()->json([
				'code'	=> '00002',
				'msg'	=> '保存成功',
				'url'	=> ''
				]);
		}
		$siteconfig = Config::where('inc_type','siteconfig')->get();
		$arr = array();
		foreach ($siteconfig as $v) {
			$arr[$v->name] = $v->value;
		}
		return view('admin.config.siteconfig',[
			'list' => $arr
			]);
	}
	
	
	/*
	 * 打印机设置
	 * */
	protected function printer(){
		return view('admin.config.printer');
	}
	
}
